#ifndef TEAM_MDLE_H
#define TEAM_MDLE_H

#include <QWidget>
#include <QStandardItemModel>
#include <QTextEdit>
#include "../../public_opt_subs/language_mdle/markdown_blck/markdownhighlighter.h"
#include <QTimer>
#include <QDateTime>
#include <QTableWidget>
#include <QLabel>
#include <QSettings>


#define NB_TEAM_SUBS_ROW_MAX 1000

namespace Ui {
class team_mdle;
}

class team_mdle : public QWidget
{
    Q_OBJECT

public:
    explicit team_mdle(QWidget *parent = nullptr);
    ~team_mdle();
//public slots:
//    void update_file_path(QList<QString>);
private slots:
    void on_ui_btm_update_dir_clicked();

    void on_ui_btm_load_clicked();

    void on_ui_box_part_currentIndexChanged(const QString &arg1);

    void on_ui_txt_head_textChanged();

    void on_ui_txt_body_textChanged();

    void on_ui_txt_foot_textChanged();

    void on_ui_tree_head_doubleClicked(const QModelIndex &index);

    void on_ui_tree_body_doubleClicked(const QModelIndex &index);

    void on_ui_tree_foot_doubleClicked(const QModelIndex &index);

    void on_ui_btm_close_clicked();

    void on_ui_btm_save_clicked();

    void on_ui_chk_auto_save_stateChanged(int arg1);

    void on_ui_btm_analysis_clicked();

    void on_ui_tree_analysis_doubleClicked(const QModelIndex &index);

    void on_ui_tree_foot_txt_doubleClicked(const QModelIndex &index);

    void on_ui_txt_head_cursorPositionChanged();

    void on_ui_txt_body_cursorPositionChanged();

    void on_ui_txt_foot_cursorPositionChanged();

    void on_ui_tree_analysis_customContextMenuRequested(const QPoint &pos);

private:
    Ui::team_mdle *ui;

    QStandardItemModel *tocModelHead;
    QStandardItemModel *tocModelBody;
    QStandardItemModel *tocModelFoot;
    QStandardItemModel *tocModelAnalysis;
    QStandardItemModel *tocModelFootTxt;

    void get_markdown_title_tree(QStandardItemModel *,QString,int);


    int title_index [3][NB_TEAM_SUBS_ROW_MAX];
    int b_load_flg;
    int lst_box_part;

    void jumpToLine(QTextEdit *, int);

    MarkdownHighlighter * highlight_md0;
    MarkdownHighlighter * highlight_md1;
    MarkdownHighlighter * highlight_md2;

    QDateTime cur_time;
    QDateTime lst_time;
    QTimer *timer;
private: // add table to analysis all file
    int n_row_max;
    QTableWidget *table_head;
    QTableWidget *table_body;
    QTableWidget *table_foot;
    QTableWidget *table_serach;
    QLabel * lab_preivew;
    void tableUpdateByFile(QString,int);
    QModelIndex anysis_index;
    QModelIndex foot_index;
    QModelIndex body_index;

private slots:
    void copy_analysis_title();
    void copy_analysis_link();
    void copy_foot_node();
    void copy_body_node();

    void on_ui_btm_serach_clicked();
    void on_ui_btm_search_all_clicked();
    void on_table_serach_double_click(int , int );

    void on_ui_btm_replace_clicked();

    void on_ui_btm_replace_all_clicked();

    void on_ui_lin_serach_textChanged(const QString &arg1);

    void on_ui_tree_analysis_clicked(const QModelIndex &index);

    void on_ui_tree_foot_txt_customContextMenuRequested(const QPoint &pos);

    void on_ui_tree_foot_txt_clicked(const QModelIndex &index);

    void on_ui_tree_body_customContextMenuRequested(const QPoint &pos);

    void on_ui_tree_body_clicked(const QModelIndex &index);

private:
    int search_scroll_site;
    //增加粘贴图片的功能
    QString saveImageFromClipboardToFile();
    //增加参数保存
    QSettings *settings;
protected:
    bool eventFilter(QObject *obj, QEvent *event) override;

};

#endif // TEAM_MDLE_H
